package com.example.demo.pattern.proxypattern;

import java.lang.reflect.Proxy;

//获取代理
public class InvocationHandlerFactory {

    public static PersonBean getOwnerPersonBeanProxy(PersonBean personBean) {
        return (PersonBean) Proxy.newProxyInstance(
                PersonBean.class.getClassLoader(),//PersonBean的类加载器
                PersonBeanImpl.class.getInterfaces(),//实现类的interface，也就是PersonBean
                new OwnerInvocationHandler(personBean)//method的invoke在此改写
        );
    }
}